home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / saveboxb.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  2.2 KB  |  80 lines

  1. ;void  save_box_b(box,top_x,top_y,width,depth);
  2. ;  unsigned char  *box,top_x,top_y,width,depth;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_page:byte
  6.  
  7. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  8.     ASSUME CS:_TEXT
  9.     PUBLIC _save_box_b
  10. _save_box_b proc near
  11.     cld            ;set direction flag
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame    
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    mov  bh,_video_page    ;set page number
  21.     cmp  _memory_model,2    ;data near or far?
  22.     jb   L0            ;jump if near
  23.     les  di,dword ptr[bp+4] ;ES:DI pts to byte array
  24.     inc  bp            ;inc BP since dword ptr
  25.     inc  bp            ;
  26.     jmp  short L00        ;
  27. L0:    mov  ax,ds        ;shift DS to ES
  28.     mov  es,ax        ;
  29.     mov  di,[bp+4]        ;NEAR case
  30. L00:    mov  dl,[bp+6]        ;topleft column in DL
  31.     dec  dl            ;count from 0
  32.     mov  dh,[bp+8]        ;topleft row in DH
  33.     dec  dh            ;count from 0
  34.     mov  al,[bp+10]        ;width in AL
  35.     dec  al            ;dec for test
  36.     cmp  al,79        ;in range?
  37.     ja   L4            ;quit if not
  38.     inc  al            ;readjust
  39.     mov  ah,[bp+12]        ;depth in AH
  40.     dec  ah            ;dec for test
  41.     cmp  ah,24        ;in range?
  42.     ja   L4            ;quit if not
  43.     inc  ah            ;readjust
  44.     mov  bp,ax        ;copy in BP
  45.     sub  cx,cx        ;clear CX
  46.     mov  cl,al        ;copy width into CX
  47.     mov  si,cx        ;move to SI as counter
  48.     mov  ah,2        ;function to set cursor
  49.     int  10h        ;set the cursor
  50.     push dx            ;save start-of-row pos
  51. L1:    mov  ah,8        ;func to read char-attri
  52.     int  10h        ;read the char and attri
  53.     stosw            ;write to the save area
  54.     dec  si            ;decrement width counter
  55.     jz   L3            ;to next row if last col
  56.     inc  dl            ;incre cursor col
  57. L2:    mov  ah,2        ;function to set cursor
  58.     int  10h        ;reset the cursor
  59.     jmp  short L1        ;go do next character
  60. L3:    pop  dx            ;new row: get old pos
  61.     mov  cx,bp        ;width-depth to CX
  62.     dec  ch            ;decre depth counter
  63.     jz   L4            ;quit if finished
  64.     mov  bp,cx        ;resave depth-width
  65.     sub  ch,ch        ;CX = width
  66.     mov  si,cx        ;transfer to SI as ctr
  67.     inc  dh            ;increase row number
  68.     push dx            ;save for next time
  69.     jmp  short L2        ;go set new cursor pos
  70. L4:    pop  si            ;
  71.     pop  di            ;
  72.     pop  bp            ;
  73.     cmp  _memory_model,0    ;quit
  74.     jle  quit        ;
  75.     db   0CBh        ;RET far
  76. quit:    ret            ;RET near
  77. _save_box_b endp
  78. _TEXT    ENDS
  79.     END
  80.